#pragma once

#include <stdint.h>

typedef int8_t dir_t;
typedef uint8_t level_t;
typedef uint8_t reached_t;
typedef int16_t cond_t;
typedef uint32_t case_t;
typedef uint64_t event_t;
typedef uint32_t closed_t;
typedef int32_t trigger_t;
typedef int8_t percent_t;
typedef int32_t volume_t;
typedef uint32_t usize_t;

typedef float price_t;
typedef float ftime_t;
typedef float risk_t;

typedef void* DATAPTR;

enum Boolean {
  False,
  True
};

typedef enum Boolean Boolean;

#ifndef CONST_CONST_CONST
#define CONST_CONST_CONST

const double phi = 0.6180339887498949;
const double ppi = 0.3819660112501051;
const double san = 0.3333333333333333;

#ifdef __cplusplus
template<typename T>
inline constexpr int8_t
sign(T val)
{
  return (T(0) < val) - (val < T(0));
}
#else
#define sign(a) ((a == 0) ? 0 : ((a > 0) ? 1 : -1))
#endif

#define FOUR_HOURS_IN_MINS  (60 * 4)
#define THREE_HOURS_IN_MINS (60 * 3)
#define TWO_HOURS_IN_MINS   (60 * 2)
#define AN_HOUR  3600
#define ONE_HALF_HOUR  3600 + 1800
#define TWO_HOURS   7200
#define MINUTES_10  10 * 60
#define MINUTES_15  15 * 60
#define MINUTES_45  45 * 60
#define MINUTES_30  30 * 60

#define HOP_FOR_COMMISION 5
#define BIG_PASS_LINE_DELTA 25

#endif // CONST_CONST_CONST

enum EVENT_CHANGE_TYPE : event_t
{
  EVENT_CHANGE_NONE = 0,
  EVENT_5DIRS_CHANGED = 1,
  EVENT_TOM_REACHED = 2,
  EVENT_JERRY_REACHED = 4,
  EVENT_MICKEY_REACHED = 8,
  EVENT_ENERGY_DIR_CHANGED = 16,
  EVENT_SWING_CHANGED = 32,
  EVENT_SWING_DIR_CHANGED = 64,
  EVENT_OPPO_OPPUR_CHANGED = 128,
  EVENT_BIG_DIR_CHANGED = 256,
  EVENT_PDC_DIR_CHANGED = 512,
  EVENT_FIGHT_DIR_CHANGED = 1024,
  EVENT_CE_DIR_CHANGED = 2048,
  EVENT_IMPORTANT_TURN = 4096,
  EVENT_BIG_NEEDLE_OCCURED = 8192,
  EVENT_TOM_CLOSED = 16384,
  EVENT_REACHED_MARK_DN = 32768,
  EVENT_RENEW_BETTER_LINES = 65536,
  EVENT_TURN_CHANGED = 131072,
  EVENT_SPACE_DIR_CHANGED = 262144,
  EVENT_SPACE_DIR_STABLE = 524288,
  EVENT_BIG_NEEDLE_DISAPPEARED = 1048576,
  EVENT_BIG_REVERSE_OCCURED = 2097152,
  EVENT_BIG_REVERSE_DISAPPEARED = 4194304,
  EVENT_EXPLICIT_DIR_CHANGED = 0x00800000,
  EVENT_LINES_CHANGED              = 0x01000000,
  EVENT_DIR_MDA_CHANGED            = 0x02000000,
  EVENT_VIRTUAL_DIR_CHANGED        = 0x04000000,
  EVENT_OPPURTUNITY_DIR_CHANGED    = 0x08000000,
  EVENT_PREDICTED_NEAR_DIR_CHANGED = 0x10000000,
  EVENT_PREDICTED_FAR_DIR_CHANGED =  0x20000000,
  EVENT_FORCE_NEAR_RT_CHANGED =   0x00040000000,
  EVENT_FORCE_FAR_RT_CHANGED =    0x00080000000,
  EVENT_FORCE_NEAR_10_CHANGED = 0x00100000000,
  EVENT_FORCE_FAR_10_CHANGED = 0x00200000000,
  EVENT_VISION_DIR_CHANGED = 0x00400000000,
  EVENT_INTENT_DIR_CHANGED = 0x00800000000,
  EVENT_VISION_WITH_SPACE = 0x01000000000,
  EVENT_TJM_DIR_CHANGED = 0x02000000000,
  EVENT_HITED_CLOSE_PRICE = 0x04000000000,
  EVENT_PREDICTED_FAR_TIME_OUT = 0x08000000000,
  EVENT_MARKED_TIME_OUT = 0x10000000000,
  EVENT_FILTER_EVENT = 0x20000000000,
  EVENT_PREDICTED_NEAR_TIME_OUT = 0x40000000000,
};

